import os
import time
import numpy as np
from matplotlib import pyplot as plt

def loading_demo():
    print("Loading",end = "")
    for i in range(10):
        print(".",end = '',flush = True)
        time.sleep(0.2)
    print("")

print("--- 检测软件环境 ---")
loading_demo()

import cv2
print(" OpenCV installed")
import torch
print(" Pytorch installed")

Path_proj = os.getcwd()
os.chdir("../yolov5")  
Path_yolo = os.getcwd()
os.chdir(Path_proj)  

print(" Project builded at", Path_proj)
print(" Yolo installed at", Path_yolo)

# print(os.getcwd())
# a = torch.cuda.is_available()
# print(a)
# device = torch.device("cuda:0" if (torch.cuda.is_available()) else "cpu")

print("--- 检测视频基本信息 ---")
loading_demo()


#————————————————
#版权声明：本文为CSDN博主「friedrichor」的原创文章，遵循CC 4.0 BY-SA版权协议，转载请附上原文出处链接及本声明。
#原文链接：https://blog.csdn.net/Friedrichor/article/details/109248340

 
#打开视频
video= cv2.VideoCapture(r'./video.avi')
 
#读取是否成功
open_not = video.isOpened()
 
#视频的宽高(分辨率)
video_width= video.get(cv2.CAP_PROP_FRAME_WIDTH)
video_height= video.get(cv2.CAP_PROP_FRAME_HEIGHT)
 
#视频总的帧数
total_frame= video.get(cv2.CAP_PROP_FRAME_COUNT)
 
#视频的帧率
fps= video.get(cv2.CAP_PROP_FPS)
 
#视频时长就是总帧数除以帧率，以秒为单位
total_time= total_frame/fps 
 
print(' video open is          {on} '.format(on=open_not))
print(' resolution:{w}x{h} '.format(w=video_width,h=video_height), ' pixels')
print(' total_frame:{af} '.format(af=total_frame), ' pics')
print(' Fps:{f} '.format(f=fps))
print(' total_time:', format(total_time, '.4f'), '  s')
print("--- 检测完成 ---")
loading_demo()
